package com.love.marriage.cloud.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.love.marriage.cloud.service.AliyunDysmsService;
import com.love.marriage.common.vo.Result;
import com.love.marriage.common.vo.ResultBoolean;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * description:  用户登录历史表restApi
 * author:       mybatisPlus
 * createDate:   2024-10-12 11:25:06
 * version:      1.0.0
 */
@ApiSort(100)
@Tag(name = "阿里云相关接口", description = "阿里云相关接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("/aliyunsms")
public class AliyunController {

    private final AliyunDysmsService aliyunDysmsService;

    @ApiOperationSupport(order = 10, author = "alex")
    @Operation(summary = "发送验证码", description = "发送验证码")
    @ApiResponse(responseCode = "200", description = "Success",
            content = @Content(mediaType = "application/json",
                    schema = @Schema(implementation = ResultBoolean.class
                    )))
    @GetMapping(value = "/sendSms")
    @Parameters({
            @Parameter(name = "phoneNum", description = "电话号", required = true),
            @Parameter(name = "message", description = "发送的消息", required = false)
    })
    @Tag(name = "公共", description = "公共接口")
    public Result<Boolean> getPage(@RequestParam(value = "phoneNum") String phoneNum,
                                   @RequestParam(value = "message", required = false) String message) throws Exception {
        return Result.success(aliyunDysmsService.sendSms(phoneNum, message));
    }
}
